# -*- coding: utf-8 -*-
"""
@Auth ： Lee
@File ：copy_files.py
@Time ： 2024/1/5 下午5:18
"""
import os
import shutil


# 将case中的pcd_top复制到指定目录下
def copy_files(source_folder, target_folder):
    if os.path.isdir(source_folder):
        for dir_name in os.listdir(source_folder):
            dir_source = os.path.join(source_folder, dir_name, "pcd")
            # dir_source = os.path.join(source_folder, dir_name)
            if os.path.isdir(dir_source):
                for pcd_dir_name in os.listdir(dir_source):
                    source_file_path = os.path.join(dir_source, pcd_dir_name, f"{pcd_dir_name}_top.pcd")
                    # source_file_path = os.path.join(dir_source, pcd_dir_name, f"{pcd_dir_name}.json")
                    try:
                        # 复制文件
                        shutil.copy(source_file_path, target_folder)
                    except FileNotFoundError:
                        print("未找到指定的文件或目录。")
                    except PermissionError:
                        print("没有足够的权限进行操作。")
                    except Exception as e:
                        print("发生了错误：", str(e))


if __name__ == '__main__':
    copy_files(r"/home/zl/Desktop/mark_data", "/home/zl/Desktop/pcds/")
